//
//  EPProgressHUD.m
//  Teacher_ZXT
//
//  Created by knrainy on 15/6/9.
//  Copyright (c) 2015年 knrainy. All rights reserved.
//

#import "EPProgressHUD.h"

@implementation EPProgressHUD
+ (void)show
{
    [SVProgressHUD show];
    SVProgressHUD.defaultMaskType = SVProgressHUDMaskTypeBlack;
}
//消失
+ (void)dismiss
{
    [SVProgressHUD dismiss];
    [SVProgressHUD dismissWithDelay:2];
}

//显示HUD
+ (void)showWithStatus:(NSString*)status
{
    [SVProgressHUD showWithStatus:status];
    SVProgressHUD.defaultMaskType = SVProgressHUDMaskTypeBlack;
    SVProgressHUD.minimumDismissTimeInterval = 1;
    [SVProgressHUD dismissWithDelay:2];
}

//显示HUD
+ (void)showWithStatus:(NSString*)status maskType:(SVProgressHUDMaskType)maskType
{
    
    [SVProgressHUD showWithStatus:status];
    SVProgressHUD.defaultMaskType = SVProgressHUDMaskTypeBlack;
    SVProgressHUD.minimumDismissTimeInterval = 1;
    [SVProgressHUD dismissWithDelay:2];
}


//显示错误信息
+ (void)showErrorWithStatus:(NSString *)string
{
    [SVProgressHUD showErrorWithStatus:string];
    SVProgressHUD.defaultMaskType = SVProgressHUDMaskTypeBlack;
    SVProgressHUD.minimumDismissTimeInterval = 1;
    [SVProgressHUD dismissWithDelay:2];
}
//显示错误信息
+ (void)showErrorWithStatus:(NSString *)string maskType:(SVProgressHUDMaskType)maskType
{
    [SVProgressHUD showErrorWithStatus:string];
    SVProgressHUD.defaultMaskType = SVProgressHUDMaskTypeBlack;
    SVProgressHUD.minimumDismissTimeInterval = 1;
    [SVProgressHUD dismissWithDelay:2];
    
}


//显示成功信息
+ (void)showSuccessWithStatus:(NSString*)string
{
    [SVProgressHUD showSuccessWithStatus:string];
    SVProgressHUD.defaultMaskType = SVProgressHUDMaskTypeBlack;
    SVProgressHUD.minimumDismissTimeInterval = 1;
    [SVProgressHUD dismissWithDelay:2];
}

//显示成功信息
+ (void)showSuccessWithStatus:(NSString*)string maskType:(SVProgressHUDMaskType)maskType
{
    [SVProgressHUD showSuccessWithStatus:string];
    SVProgressHUD.defaultMaskType = SVProgressHUDMaskTypeBlack;
    SVProgressHUD.minimumDismissTimeInterval = 1;
    [SVProgressHUD dismissWithDelay:2];
}

#pragma mark - error HUD
//显示错误HUD
+ (void)showErrorHUD:(NSError *)error
{
    switch (error.code)
    {
        case NSURLErrorTimedOut:
            [EPProgressHUD showErrorWithStatus:@"加载失败,网络超时" maskType:SVProgressHUDMaskTypeBlack];
            break;
        case NSURLErrorNotConnectedToInternet:
            [EPProgressHUD showErrorWithStatus:@"网络未连接,请检查网络设置。" maskType:SVProgressHUDMaskTypeBlack];
            break;
        case NSURLErrorCannotConnectToHost:
            [EPProgressHUD showErrorWithStatus:@"网络连接断开" maskType:SVProgressHUDMaskTypeBlack];
            break;
        default:
            [EPProgressHUD showErrorWithStatus:@"网络连接断开" maskType:SVProgressHUDMaskTypeBlack];
            break;
    }
}

@end
